<?php
$T->loadTpl("./html/".$template."/".$qname.".html");
$T->SetTpl('cssjs','html/cssjs.inc'); 
$T->SetTpl('jsmodel','html/jsmodel.inc');     
  
$p=isset($_GET["p"])?$_GET["p"]:"1";
$t=isset($_GET["type"])?$_GET["type"]:"";
$start_date=isset($_GET["start_date"])?$_GET["start_date"]:"";
$end_date=isset($_GET["end_date"])?$_GET["end_date"]:"";
$where = " and uid ='".$_SESSION['uid']."'";
if(!empty($t)&&$t!='all'){$where.=" and type=".$t;$T->Set('type',$t);}
if($start_date){$where.=" and time>='".date('Y-m-d H:i:s',strtotime($start_date))."'";$T->Set('start_date',$start_date);}
if($end_date){$where.=" and time<='".date('Y-m-d H:i:s',strtotime($end_date)+86400)."'";$T->Set('end_date',$end_date);}
$offset = ($p-1)*15;
$uid=$_SESSION['uid'];
$list =$T->db->query("select * from sys_worklogs where 1=1 ".$where." order by time desc  limit {$offset},15")->fetchAll(PDO::FETCH_ASSOC);
$str_html = '';
foreach ($list as $k => $val) {
    $content =  strip_tags($val['content']);
    $type = $T->db->query("select name from sys_worklogs_type where uid='".$uid."' and id=".$val['type'])->fetchColumn(0);
    $str_html.='<tr>
                    <td>
                        <input type="checkbox" name="checkbox" lay-skin="primary" value="'.$val["id"].'"/>
                    </td>
                    <td>'.$val["id"].'</td>
                    <td>'.$type.'</td>
                    <td class="ellipsis">'.$content.'</td>
                    <td>'.$val["time"].'</td>
                    <td>    
                        <button class="layui-btn layui-btn-mini layui-btn-normal ajax"  data-opt="view"  data-id="'.$val["id"].'">
                            <i class="iconfont">&#xe605;</i>查看
                        </button>
                        <button class="layui-btn layui-btn-mini layui-btn-danger ajax"  data-opt="del"  data-id="'.$val["id"].'">
                            <i class="iconfont">&#xe626;</i>删除
                        </button>
                    </td>
                </tr>';
}
$rc=$T->db->query("select count(*) from sys_worklogs where 1=1".$where)->fetchColumn(0);
if($p<1)$p=1;
$page=getPageHtml_bt($rc,15,$p,"&t=worklogs_sys");
$page=mb_convert_encoding($page, 'utf-8', 'utf-8');
$T->SetBlock("types","select id,name from sys_worklogs_type where uid='".$uid."' order by odx");
$T->Set("page",$page);
$T->Set("str_html",$str_html);
        
$T->Set("template",$template);         
$T->clearNaN();       
$T->clearNoN();
$T->display(); 